﻿Imports Exp.Model
Imports Exp.DATA_Service

Public Class ChangePassword1
    Inherits BasePage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load        

    End Sub

    Protected Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
        Response.Redirect("Profile.aspx")
    End Sub

    Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
        Dim usr As REM_User = Session("USER")

        Dim oldPwd = GetDataUtil.getMD5Hash(txtOldPwd.Text.Trim())
        Dim newPwd = GetDataUtil.getMD5Hash(txtNewPwd.Text.Trim())

        If oldPwd <> usr.Password Then
            lblStatus.Visible = True
        Else
            Dim da As New User_Service()

            If da.UpdatePassword(usr.User_ID, newPwd) Then
                usr.Password = newPwd
                Response.Redirect("Profile.aspx")
            Else
                'Error Handle
                Response.Redirect("Profile.aspx")
            End If

        End If
    End Sub
End Class